//
//  GDTrainModelCell.m
//  GraduationDesign
//
//  Created by JiaKang.Zhong on 16/1/7.
//  Copyright © 2016年 JiaKang.Zhong. All rights reserved.
//

#import "GDTrainModelCell.h"
#import "GDTrainView.h"

@interface GDTrainModelCell ()

@property(nonatomic,weak) GDTrainView * trainView;

@end
@implementation GDTrainModelCell

+(instancetype)cellWithTableView:(UITableView *)tableView and:(NSIndexPath *)indexPath{
    
    static NSString * ID = @"GDTrainModelCell";
    GDTrainModelCell * cell =  [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[GDTrainModelCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
    }else{
        for (UIView * view in [cell.trainView.ticketView subviews]) {
            if ([view isKindOfClass:NSClassFromString(@"UILabel")]) {
                [view removeFromSuperview];
            }
        }
    }
    //  选中无背景颜色
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    return cell;
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor clearColor];
        [self setUpChildSubviews];
    }
    return self;
}



#pragma mark 创建view
-(void) setUpChildSubviews{
    GDTrainView * trainView = [[GDTrainView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, GDSHOWTABLEVIEWCELLHEIGHT)];
    [self addSubview:trainView];
    _trainView = trainView;
    
}


#pragma mark 设定模型
-(void)setViewModel:(GDTrainViewModel *)viewModel{

    self.trainView.viewModel = viewModel;
       
}

@end
